# 指定 CMake 最低版本要求
cmake_minimum_required(VERSION 3.16)

# 设置项目名称和版本
project(MySbotPlugin VERSION 0.1 LANGUAGES CXX)

# 定义安装目录
set(INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../BuildPlugins)

# 定义 Sbot 插件接口目录
set(SBOT_PLUGIN_INC ../../Sbot/Inc)
set(SBOT_PLUGIN_SRC ../../Sbot/Src/SbotPlugin.cpp)

# 启用自动 MOC，RCC 功能
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# 指定 C++ 标准版本为 C++11，并要求编译器严格遵循该标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找并加载 Qt 模块
find_package(Qt6 COMPONENTS Core Quick REQUIRED)

# 获取头文件
file(GLOB HEADERS
    *.h
    ./Inc/*.h
    ./Lib/*.h
)

# 获取源文件
file(GLOB SOURCES
    *.c
    *.cpp
    ./Src/*.c
    ./Src/*.cpp
    ./Lib/*.c
    ./Lib/*.cpp
)

# 添加资源文件到项目中
qt_add_resources(RESOURCE
    ./resources.qrc
)

# 添加共享库
add_library(${PROJECT_NAME} SHARED
    ${HEADERS}
    ${SOURCES}
    ${RESOURCE}
    ${SBOT_PLUGIN_SRC}
)

# 添加头文件路径到项目中
target_include_directories(${PROJECT_NAME} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/Inc
    ${SBOT_PLUGIN_INC}
)

# 链接所需的库
target_link_libraries(${PROJECT_NAME}
    PRIVATE
    Qt6::Core
    Qt6::Quick
)

# 设置动态链接库文件名前缀为空字符串
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")

# 指定安装目录
install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_DIR})
